//class Shape {
//    public void draw() {
//        System.out.println("图形");
//    }
//}
//class Rectangle extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("rectangle");
//    }
//}
//class Circle extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("circle");
//    }
//}
//class Flower extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("flower");
//    }
//}
//public class Main {
//    public static void func(Shape shape) {
//        shape.draw();
//    }
//    public static void main(String[] args) {
//Rectangle rectangle = new Rectangle();
//Circle circle = new Circle();
//func(rectangle);
//func(circle);
//func(new Flower());
//    }
//}


//不采用多态（比起下述代码要复杂）
//class Rectangle {
//    public void draw() {
//        System.out.println("rectangle");
//    }
//}
//class Circle {
//    public void draw() {
//        System.out.println("circle");
//    }
//}
//class Flower {
//    public void draw() {
//        System.out.println("flower");
//    }
//}
//public class Main {
//    public static void main(String[] args) {
//        Rectangle rectangle = new Rectangle();
//        Circle circle = new Circle();
//        Flower flower = new Flower();
//        String[] shapes = {"rectangle", "circle", "flower"};
//        for (String shape : shapes) {
//            if(shape.equals("rectangle")) {
//             rectangle.draw();
//            } else if(shape.equals("circle")) {
//                circle.draw();
//            } else if(shape.equals("flower")) {
//                flower.draw();
//            }
//        }
//
//    }
//}


//class Shape {
//    public void draw() {
//        System.out.println("图形");
//    }
//}
//class Rectangle extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("rectangle");
//    }
//}
//class Circle extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("circle");
//    }
//}
//class Flower extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("flower");
//    }
//}
//public class Main {
//    public static void main(String[] args) {
//        Shape[] shapes = {new Rectangle(), new Circle(), new Flower()};
//        for (Shape shape : shapes) {
//            shape.draw();
//        }
//    }
//}


//class Shape {
//    public void draw() {
//        System.out.println("图形");
//    }
//}
//
//class Rectangle extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("rectangle");
//    }
//}
//
//class Circle extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("circle");
//    }
//}
//
//class Flower extends Shape {
//    @Override
//    public void draw() {
//        System.out.println("flower");
//    }
//}
//
//public class Main {
//    public static void drawMap(Shape shape) {
//        shape.draw();
//    }
//
//    public static void main(String[] args) {
//        drawMap(new Rectangle());
//        drawMap(new Circle());
//        drawMap(new Flower());
//    }
//}




























